<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../JS/react.development.js"></script>
    <script src="../../JS/react-dom.development.js"></script>
    <script src="../../JS/babel.min.js"></script>
</head>
<body>
    <div id="root"></div>
    <script type="text/babel">
        class HelloName extends React.Component {
            // 定义click事件的处理方法
            fnHello() {
                alert("hello " + this.props.name);
            }
            render() {
                return (
                    // 在事件调用方法时 如果方法里面使用了this 在方法中需要绑定this
                    <input type="button" value="打招呼" onClick={this.fnHello.bind(this)}/>
                )
            }
        }

        ReactDOM.render(<HelloName name="ADD" />, document.getElementById('root'));
    </script>
</body>
</html>